import { getQuestionList, } from '@/services';
import { IQuestionList, IQuestionListQuery } from '@/utils/questions';
import { makeAutoObservable } from 'mobx';

class Question {
    constructor() {
        makeAutoObservable(this)
    };
    //评论数量小图标
    xx: string = ""

    //问题数据列表变量
    questionList: IQuestionList[] = []
    //问题数据数据列表长度
    questionListLen: number = 0
    //分页
    pageNum: number = 1
    setPAgeNum(e: number) {
        this.pageNum = e
    }
    //类型状态
    curgenre = ""
    setCurgenre(type: string) {
        this.curgenre = type
    }
    // quality: 1 只看精品
    quality = ""
    setQuality(e: boolean) {
        this.quality = e == true ? "1" : ""
    }
    // authentication:  //只看讲师
    authentication = ""
    setAuthentication(e: boolean) {
        e ? this.authentication = "1" : this.authentication = ""
    }
    //模糊搜索

    title = ""
    questionTitle = ""
    setTitle(e: string) {
        this.title = e
    }
    setQuestionTitle(title: string) {
        this.questionTitle = title
    }

    //数据列表请求
    async getQuestionList(params: IQuestionListQuery) {
        let res = await getQuestionList(params)
        if (res.rows) {
            this.questionList = res.rows
            this.questionListLen = res.total
        }
    }
}

export default new Question